<#if classPath??>
package ${classPath};
</#if>
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import ${classPathShort}.model.${Entity};
import ${classPathShort}.repository.${Repository};
import ${classPathShort}.service.${Service};
import ${classPathShort}.model.dto.${DTO};
import com.cloume.commons.rest.response.RestResponse;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.*;
import javax.annotation.Resource;


@Service
public class ${ServiceImpl} implements ${Service} {
    @Resource
    private ${Repository} ${Repository ? uncap_first};

    @Override
    public ${List}<${Entity}> findAll${Entity}() {
        return ${Repository ? uncap_first}.findAll();
    }

    @Override
    public ${Entity}  find${Entity}ById(${idType} id) {
        Optional<${Entity}> ${Entity ? uncap_first} = ${Repository ? uncap_first}.findById(id);
         if(${Entity ? uncap_first}.isPresent()){
            return ${Entity ? uncap_first}.get();
            }
         return new ${Entity}();
      }
    @Override
    public Page<${Entity}> find${Entity}ByPage( ${DTO}  ${DTO ? uncap_first}) {
        //return ${Repository ? uncap_first}.find${Entity}ById(id);
        return null;
    }
    @Override
    public ${Entity} add${Entity}(${DTO} ${DTO ? uncap_first}) {
       ${Entity} ${Entity ? uncap_first}= ${Entity}.convertTo${Entity}(${DTO ? uncap_first});
       return ${Repository ? uncap_first}.save(${Entity ? uncap_first});
    }
    @Override
    public ${Entity} update${Entity}(${DTO} ${DTO ? uncap_first}) {
       ${Entity} ${Entity ? uncap_first}= ${Entity}.convertTo${Entity}(${DTO ? uncap_first});
       return ${Repository ? uncap_first}.save(${Entity ? uncap_first});
    }


    @Override
    public void delete${Entity}(${List}<${idType}> ids) {
        if(ids!=null && ids.size()>0){
        for (${idType} id : ids) {
            if(${Repository ? uncap_first}.existsById(id)){
             ${Repository ? uncap_first}.deleteById(id);
                    }
                }
            }
        }
}